

#include "filter_util.h"

FilterScopeGuard::FilterScopeGuard()
{

}

FilterScopeGuard::~FilterScopeGuard()
{
	for (auto iter = m_inout_vec.begin(); iter != m_inout_vec.end(); )
	{
		auto delete_ptr = *iter;

		// delete delete_ptr;
		avfilter_inout_free(&delete_ptr);

		iter = m_inout_vec.erase(iter);
	}
	for (auto iter = m_filter_ctx_vec.begin(); iter != m_filter_ctx_vec.end(); )
	{
		auto delete_ptr = *iter;

		iter = m_filter_ctx_vec.erase(iter);

		avfilter_free(delete_ptr);
	}
}

void FilterScopeGuard::AddFilterInOut(AVFilterInOut *inout)
{
	m_inout_vec.push_back(inout);
}

void FilterScopeGuard::AddFilterCtx(AVFilterContext *filter_ctx)
{
	m_filter_ctx_vec.push_back(filter_ctx);
}


void FilterScopeGuard::ClearInOut()
{
	m_inout_vec.clear();
}

void FilterScopeGuard::ClearFilterCtx()
{
	m_filter_ctx_vec.clear();
}